﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DAL;
using BLL;
using BOL;
using DevComponents.DotNetBar;

namespace QuanLyHangXeKhach
{
    public partial class frmChuNangNhanVien : DevComponents.DotNetBar.Controls.SlidePanel
    {
        public string tentaikhoan;
        ChucNangNhanVien chucnang = new BLL.ChucNangNhanVien();

        public frmChuNangNhanVien()
        {
            InitializeComponent();
        }

        #region Điều khiển đóng/mở form
        private DieuKhien _Commands;
        /// <summary>
        /// Gets or sets the commands associated with the control.
        /// </summary>
        public DieuKhien Commands
        {
            get { return _Commands; }
            set
            {
                if (value != _Commands)
                {
                    DieuKhien oldValue = _Commands;
                    _Commands = value;
                    OnCommandsChanged(oldValue, value);
                }
            }
        }
        /// <summary>
        /// Called when Commands property has changed.
        /// </summary>
        /// <param name="oldValue">Old property value</param>
        /// <param name="newValue">New property value</param>
        protected virtual void OnCommandsChanged(DieuKhien oldValue, DieuKhien newValue)
        {
            if (newValue != null)
            {
                btnxemtt.Command = newValue.showthongtin;
                btndangxuat.Command = newValue.dangxuat;
                btnnd.Command = newValue.shownoiden;
                btncapnhatnoidi.Command = newValue.shownoidi;
                btncapnhatdiemdungchan.Command = newValue.showdiemdung;
                btncapnhattuyendg.Command = newValue.showcntuyenduong;
                btngiatuyendg.Command = newValue.showcngiatuyen;
                btncapnhatnvpt.Command = newValue.showcnnvpt;
                btncapnhatxe.Command = newValue.showcnxe;
                btncapnhatlichchay.Command = newValue.showcnlichchay;
                btncapnhatkhachhang.Command = newValue.showcnkhachhang;
                btncapnhatnhanvien.Command = newValue.showcnnhanvien;
                btnbanve.Command = newValue.showbanve;


            }
            else
            {
                btnxemtt.Command = null;
                btndangxuat.Command = null;
                btnnd.Command = null;
                btncapnhatnoidi.Command = null;
                btncapnhatdiemdungchan.Command = null;
                btncapnhattuyendg.Command = null;
                btngiatuyendg.Command = null;
                btncapnhatnvpt.Command = null;
                btncapnhatxe.Command = null;
                btncapnhatlichchay.Command = null;
                btncapnhatkhachhang.Command = null;
                btncapnhatnhanvien.Command = null;
                btnbanve.Command = null;
            }
        }

        #endregion

        private void frmChucNangNhanVien_Load(object sender, EventArgs e)
        {
            Loadthongtinnv();
        }

        public void Loadthongtinnv()
        {
           // pageSlider1.SelectedPageIndex = 0;

            List<thongtinnhanvien> thongtin = chucnang.laynhanvien(tentaikhoan);
            foreach (var row in thongtin)
            {
                lbltennv.Text = row.ten;
                lblchucvu.Text = row.chucvu;

                //load ảnh
                Image img = Image.FromStream(row.hinhanh);
                if (img == null) return;
                picavatar.SizeMode = PictureBoxSizeMode.StretchImage;
                picavatar.Image = img;
                
            }
        }
        
        protected override void OnResize(EventArgs e)
        {
          
            // Center the panel
            panelEx1.Location = new Point((this.Width - panelEx1.Width) / 2 , (this.Height  - panelEx1.Height) / 2);
            base.OnResize(e);
        }

        private void buttonX2_Click(object sender, EventArgs e)
        {
           //pageSlider1.SelectedPageIndex = 0;
        }

        private void btncapnhat_Click(object sender, EventArgs e)
        {
           // pageSlider1.SelectedPageIndex = 0;
        }

        private void btntracuu_Click(object sender, EventArgs e)
        {
            //pageSlider1.SelectedPageIndex = 1;
        }

        private void btnthongke_Click(object sender, EventArgs e)
        {
            //pageSlider1.SelectedPageIndex = 2;
        }

        
    }
}
